package cn.demarcia.coco.ui.adapter;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

import com.viewpagerindicator.IconPagerAdapter;

import java.util.ArrayList;
import java.util.List;

import cn.demarcia.coco.AppConfig;
import cn.demarcia.coco.ui.activity.JokeActivity;
import cn.demarcia.coco.ui.fragment.JokeViewPager;
import cn.demarcia.coco.ui.fragment.NewsViewPager;

/**
 * Created by lzy
 * on 2016/8/9.
 */
public class JokePagerAdapter extends FragmentPagerAdapter implements IconPagerAdapter {
    protected List<Fragment> pagers = new ArrayList<>();
    private Context context;
    private static final String[] TYPE = new String[]{
            AppConfig.JOKE_TEXT, AppConfig.JOKE_PICTURE};

    public JokePagerAdapter(Context context, FragmentManager supportFragmentManager) {
        super(supportFragmentManager);
        this.context = context;
        pagers.add(JokeViewPager.getInstance(AppConfig.JOKE_TEXT));
        pagers.add(JokeViewPager.getInstance(AppConfig.JOKE_PICTURE));
    }

    @Override
    public Fragment getItem(int position) {
        return pagers.get(position);
    }

    @Override
    public int getIconResId(int index) {
        return 0;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return TYPE[position];
    }

    @Override
    public int getCount() {
        return TYPE.length;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        return super.instantiateItem(container, position);
    }
}
